import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import px2rem from "postcss-px2rem";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";



export default defineConfig({
	plugins: [vue(),
		AutoImport({
			resolvers: [ElementPlusResolver()],
		}),
		Components({
			resolvers: [ElementPlusResolver()],
		}),
	],
	resolve: {
		alias: {
			"@": resolve(__dirname, "src"), // 路径别名
			'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
		},
	},
  
	//自适应设置
	css: {
		postcss: {
			plugins: [
				px2rem({
					remUnit: 190,
					// propList: ['*'], // 需要转换的属性，这里选择全部都进行转换
				})
			]
		},
        preprocessorOptions: {
			less: {
				modifyVars: {
					hack: `true; @import (reference) "${resolve("src/style/base.less")}";`,
				},
				javascriptEnabled: true,
			},
		},
	},
	server: {
	  host: "0.0.0.0",
	  port: 8080,
	  proxy: {
	    "/api": {
	      target:"https://globaleasybuysystem.com/api", 
	      changeOrigin: true,
	      rewrite: (path) => path.replace(/^\/api/, ""),
	    },
	  },
	},
	base: "./",
	build: {
	  outDir: "E:/GOdoo11PY3/myaddons/buyer_portal/static/contact",
	  assetsDir: "js",
	  manifest: false,
	  rollupOptions: {
		output: {
		  entryFileNames: `js/[name]${(Math.random()*10+1).toFixed(2)}.js`,
		  chunkFileNames: `js/[name]${(Math.random()*10+1).toFixed(2)}.js`,
		  assetFileNames: `js/[name]${(Math.random()*10+1).toFixed(2)}.[ext]`,
		},
	  },
	},

});
 
